package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.common.api.ResultCode;
import com.ytjj.qmyx.admin.model.request.forum.ForumLiveInfoRequest;
import com.ytjj.qmyx.admin.model.request.forum.ForumLiveRequest;
import com.ytjj.qmyx.admin.service.ForumLiveService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description 9.9生活馆
 * @ClassName ForumLiveController
 *
 * 
 * @Version 1.0
 **/
@RestController
@RequestMapping("/forumLive")
public class ForumLiveController {

    @Resource
    private ForumLiveService forumLiveService;
    /**
     * @Description 添加9.9生活馆版块信息
     *
     *
     *
     * @Version 1.0
     **/
    @PostMapping("/addForumLive")
    public CommonResult addForumInfo(@RequestBody ForumLiveRequest forumLiveRequest) {
        forumLiveService.addForumLive(forumLiveRequest);
        return CommonResult.success(ResultCode.SUCCESS);
    }

    /**
     * @Description 编辑版块信息
     *
     *
     * 
     * @Version 1.0
     **/
    @PostMapping("/editForumLive")
    public CommonResult editForumLive(@RequestBody ForumLiveRequest forumLiveRequest)  {
        forumLiveService.editForumLive(forumLiveRequest);
        return CommonResult.success(ResultCode.SUCCESS);
    }

    /**
     * @Description 获取版块列表
     *
     *
     * 
     * @Version 1.0
     **/
    @GetMapping("/getForumLiveList")
    public CommonResult getForumLiveList(@RequestParam(value = "status", required = false) Integer status,
                                         @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                         @RequestParam(value = "pageNum", required = false) Integer pageNum) {
        return CommonResult.success(forumLiveService.getForumLiveList(status, pageSize, pageNum));
    }

    /**
     * 移除版本-delete
     * @param id
     * @return
     */
    @GetMapping("/removeForum")
    public CommonResult removeForum(@RequestParam("id") Integer id) {
        forumLiveService.removeForum(id);
        return CommonResult.success(ResultCode.SUCCESS);
    }

    /**
     * @Description 移除版块信息-update
     *
     *
     * 
     * @Version 1.0
     **/
    @GetMapping("/removeForumLive")
    public CommonResult removeForumLive(@RequestParam("id") Integer id) {
        forumLiveService.removeForumLive(id);
        return CommonResult.success(ResultCode.SUCCESS);
    }

    /**
     * @Description 根据版块id获取版块商品信息
     *
     *
     * 
     * @Version 1.0
     **/
    @GetMapping("/getForumLiveProductList")
    public CommonResult getForumLiveProductList(@RequestParam("id") Integer id,
                                                @RequestParam("pageSize") Integer pageSize,
                                                @RequestParam("pageNum") Integer pageNum) {
        return CommonResult.success(forumLiveService.getForumLiveProductList(id, pageSize, pageNum));
    }


    @PostMapping("/searchForumLiveProductList")
    public CommonResult searchForumLiveProductList(@RequestBody ForumLiveInfoRequest forumLiveInfoRequest) {
        return CommonResult.success(forumLiveService.searchForumLiveProductList(forumLiveInfoRequest));
    }

    @GetMapping("/updateIsRecommend")
    public CommonResult updateIsRecommend(@RequestParam("forumLiveId") Integer forumLiveId,
                                          @RequestParam("productId") Integer productId, @RequestParam("isRecommend") Integer isRecommend) {
        forumLiveService.updateIsRecommend(forumLiveId, productId, isRecommend);
        return CommonResult.success();
    }

    /**
     * @Description 查询商品
     *
     *
     * 
     * @Version 1.0
     **/
    @GetMapping("/searchProduct")
    public CommonResult searchProduct(@RequestParam("productId") Integer productId,
                                      @RequestParam("productName") String productName,
                                      @RequestParam(value = "platformData",required = false) String platformData) {
        return CommonResult.success(forumLiveService.searchProduct(productId, productName, platformData));

    }

    /**
     * @Description 新增9.9栏目商品
     *
     *
     * 
     * @Version 1.0
     **/
    @GetMapping("/addForumProduct")
    public CommonResult addForumProduct(@RequestParam("productId") Integer productId,
                                        @RequestParam("forumLiveId") Integer forumLiveId) {
        forumLiveService.addForumProduct(productId, forumLiveId);
        return CommonResult.success(ResultCode.SUCCESS);
    }

    /**
     * @Description 移除生活馆版块商品
     *
     *
     * 
     * @Version 1.0
     **/
    @GetMapping("/deleteForumProduct")
    public CommonResult deleteForumProduct(@RequestParam("id") Integer id) {
        forumLiveService.deleteForumProduct(id);
        return CommonResult.success(ResultCode.SUCCESS);
    }


    /**
     * @Description 更新商品排序
     *
     *
     * 
     * @Version 1.0
     **/
    @GetMapping("/updateForumProductSort")
    public CommonResult updateForumProductSort(@RequestParam("id") Integer id,
                                               @RequestParam("sort") Integer sort) {
        forumLiveService.updateForumProductSort(id, sort);
        return CommonResult.success(ResultCode.SUCCESS);
    }


    /**
     * @Description 获取分类
     *
     *
     * 
     * @Version 1.0
     **/
    @GetMapping("/getCategory")
    public CommonResult getCategory() {
        return CommonResult.success(forumLiveService.getCategory());
    }


}
